package com.baizhi.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @GetMapping("/demo")
    //熔断之后的快速响应
    @HystrixCommand(fallbackMethod ="demoFallback")
    public String demo(Integer id) {
        if (id <= 0) {
            throw new RuntimeException("无效id");
        }
        return "Demo ok";
    }

    public String demoFallback(Integer id) {
        return "当前活动火爆,服务爆炸";
    }
}
